function addToAlbum(obj){
	var htmlCode = '<ul class = "albumUL">'
					// + '<li class="check"><input class="checkBox" type="checkbox"/></li>'
					 + '<li class="titleLi">' +  $(obj).next().attr('value') + '<input type="hidden" value=' + $(obj).attr('id') + ' name="photoId" /></li>'
					 + "<li class='descLi'><input onclick='this.value=" + "\"\"" + "' style='height:12px;width:200px' width='250px' type='text' name='desc' value='Photo Desc' maxLength='200'/></li>"
					 + '<li class="editLi"><a class="delete" href="#">Remove</a></li>'
				 + '</ul>';
	$("#albumPhotos").append(htmlCode);
	$('.delete').click(function(){
		$(this).parent().parent().remove();
		
	});
};

ajaxPhotoPage = function(){
	$('#pager a').click(function(){
		event.preventDefault();
		var urls = $(this).attr('href').split('?');
		var url = urls[0];
		var data='';
		if(urls.length > 1){
			data = {'pageNo':urls[1].split('=')[1]};
		}
		$.post(url,
				data,
				function(htmlData){
					$("#galleriaPage").replaceWith(htmlData);
					galleriaInit();
					ajaxPhotoPage();
				},
				'html');
		
	});
};

galleriaInit = function(){
	$('#galleria').galleria({
	
		transition_speed: 1000,
		data_config: function(img) {
			// will extract and return image captions from the source:
			return  {
				title: $(img).parent().next('span').html(),
				description:$(img).parent().next('span').next().html()
			};
		}
	});
};

$(function(){
	galleriaInit();
	$('.delete').click(function(){
		$(this).parent().parent().remove();
		
	});

	ajaxPhotoPage();
	$("#albumCreate").validationEngine({
		promptPosition: "topRight", // OPENNING BOX POSITION, IMPLEMENTED: topLeft, topRight, bottomLeft,  centerRight, bottomRight
		success :  false,
		failure : function(){}
	});
	
});